package com.example.system.controller.question;

import com.example.core.controller.BaseController;
import com.example.core.domain.R;
import com.example.core.domain.TableDataInfo;
import com.example.system.domain.question.Question;
import com.example.system.domain.question.dto.QuestionAddDTO;
import com.example.system.domain.question.dto.QuestionEditDTO;
import com.example.system.domain.question.dto.QuestionQueryDTO;
import com.example.system.domain.question.vo.QuestionDetailVO;
import com.example.system.domain.question.vo.QuestionVO;
import com.example.system.service.question.IQuestionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-12-02
 * Time: 17:17
 */
@RestController
@RequestMapping("/question")
@Tag(name = "题目管理接口")
public class QuestionController extends BaseController {

    @Autowired
    private IQuestionService questionService;


    @Operation(summary = "获取题目")
    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO) {
        return getTableDataInfo(questionService.list(questionQueryDTO));
    }

    //question/add
    @Operation(summary = "添加题目")
    @PostMapping("/add")
    public R<Void> add(@RequestBody QuestionAddDTO questionAddDTO){
        return toR(questionService.add(questionAddDTO));
    }

    @Operation(summary = "获取详细")
    @GetMapping("/detail")
    public R<QuestionDetailVO> detail(long questionId){
        return R.ok(questionService.detail(questionId));
    }

    @Operation(summary = "修改")
    @PutMapping("/edit")
    public R<Void> edit(@RequestBody QuestionEditDTO questionEditDTO) {
        return toR(questionService.edit(questionEditDTO));
    }
    @DeleteMapping("/delete")
    public R<Void> delete(long questionId){
        return toR(questionService.delete(questionId));
    }
}
